<template>
    <div class="layui-form-item">
        <label class="layadmin-user-login-icon layui-icon <%= icon %>"></label>
        <input type="<%= inputType %>" name="<%= name %>" id="<%= 'input-' + inputType +'-'+ name %>"
            <% if ( verify ) { %> lay-verify="<%= verify %>" <% } %> placeholder="<%= placeholder %>"
            class="layui-input">
    </div>
</template>
<script name="compile">
    function templateCompile(data) {
        var defaultData = {
            type: "module",
            placeholder: "",
            inputType: "text",
            verify: false,
            comparedList: false
        };
        var newData = Object.assign(defaultData, data);
        var callback = {
            success: true,
            result: newData
        };
        if (!newData.placeholder) {
            return {
                success: false,
                result: "请输入表单提示，参数名：placeholder"
            };
        }
        if (!newData.name) {
            return {
                success: false,
                result: "请输入参数名称，参数名：name"
            };
        }
        if (!newData.icon) {
            return {
                success: false,
                result: "请选择表单图标，参数名：icon"
            };
        }
        return callback;
    }
</script>
<script name="templateScript">
    <% if(comparedList){ %>
        //&&insertStart:(scriptchildren1)&&
        <% comparedList.forEach(function (item) { %>
            if (data.<%- name %> != data.<%- item.name %>) {
            popup.msg("<%- item.prompt %>");
            return false;
        }
        <% }); %>
        //&&insertEnd&&
    <% }; %>
</script>